package com.gary.spring.awreInit;

import com.gary.spring.bean.Bean2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * @author peng_rui
 * @date 2022/6/26
 */
@Configuration
public class MyConfig1 {

    @Autowired
    public void setApplicationContext(ApplicationContext context) {
        System.out.println("context " + context);
    }

    @PostConstruct
    public void init() {
        System.out.println("config1 初始化");
    }

    @Bean
    public BeanFactoryPostProcessor beanFactory() {
        return beanFactory -> {
            System.out.println("beanFactory... + 自注入 beanFactory");
        };
    }
}
